/*
 * Copyright (c) 2006-2021, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 * 2021-04-05     andy       the first version
 */

#include "devDataBase.h"

#include "string.h"

#define LOG_TAG     "devDB"       // 该模块对应的标签。不定义时，默认：NO_TAG
#define LOG_LVL     LOG_LVL_DBG   // 该模块对应的日志输出级别。不定义时，默认：调试级别
#include <ulog.h>                 // 必须在 LOG_TAG 与 LOG_LVL 下面






/*****************************************
 * I函数名称：rt_err_t fs_WIFI_CONFIG_reload(void)
 * I参数：

 * I
 * I功能：    从  WIFI_CONFIG_FILE: wificonfig.ini 文件中读取SSID 和 PASSWORD
 * I注意设置命令  echo "SSID:xjaujsjandy PASSWORD:1223334444" wificonfig.ini
 * *****************************************/
char g_wifi_SSID[WIFI_CONFIG_LEN];              //wifi ssid
char g_wifi_PASSWD[WIFI_CONFIG_LEN];            //wifi password
rt_err_t fs_WIFI_CONFIG_reload(void)
{

    rt_memcpy(g_wifi_SSID, WIFI_DEF_SSID, sizeof(WIFI_DEF_SSID));               //文件配置读取失败，使用默认SSID
    rt_memcpy(g_wifi_PASSWD, WIFI_DEF_PASSWD, sizeof(WIFI_DEF_PASSWD));         //文件配置读取失败，使用默认PASSWORD
    log_d("wifi config file:%s read failed, default ssid = %s password = %s", WIFI_CONFIG_FILE,g_wifi_SSID, g_wifi_PASSWD);


    //---------I读取到的SSID 和 PASSWD 验证I---------------
    if(WIFI_CONFIG_MINLEN < rt_strlen(g_wifi_SSID) && WIFI_CONFIG_MINLEN < rt_strlen(g_wifi_PASSWD))
    {
        return RT_EOK;     //有效的SSID 和 password
    }


    return RT_ERROR;
}








//void fs_configuration_wait(int argc, char**argv)
//{
//    const uint8_t WAIT_TIME_MAX = 60*2;
//
//    g_fsConfig_waitTime = atoi(argv[1]);
//    log_d("main thread will wait %d S for you to config\r\n",g_fsConfig_waitTime);
//
//    if(g_fsConfig_waitTime <= WAIT_TIME_MAX)
//    {
//        return RT_EOK;
//    }
//    else {
//        log_e("wait time should less than %d S\r\n",WAIT_TIME_MAX);
//    }
//
//}

//MSH_CMD_EXPORT(fs_configuration_wait,  fs_configration_wait [TIME in secends] )












